package com.haozi.config;

import com.haozi.constants.ConfigConstant;
import com.haozi.exception.SystemException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author zyh
 * @version 1.0
 * @date 2022/4/29 4:03 下午
 */
@Component
public class DataSourceConfigFactory {


    @Autowired
    GlobalConfig globalConfig;

    public DataSourcelConfig dataSourcelConfig() {

        String properties = globalConfig.getProperties(ConfigConstant.DATA_SOURCE_TYPE);

        if (ConfigConstant.DATA_SOURCE_TYPE_BAIDU.equals(properties)) {
            return new BaiduConfig();
        }
        throw new SystemException("暂不支持该数据源");
    }

}
